#pragma once

#include <Arduino.h>

// 定义函数
typedef void (*CallBackFunction)(int index);

class AsyncTime
{
private:
  int _index = 0;
  int _oldIndex = 0;
  int _maxIndex = 0;
  int _time = 0;
  unsigned long _currentTime = 0;
  unsigned long _previousTime = 0;

public:
  AsyncTime(int index = 0, int maxIndex = 0, int millisecond = 0);

  void start(CallBackFunction callback, bool startCallback);

  void clearPreviousTime();

  void initIndex();

  void setTime(int value);

  void clear();
};